<?php
class App_Module_Admin_Component_Articles_Tpl_Comments extends App_Module_Admin_Tpl_List
{
	protected $_showCells = array('comment', 'icons');
	protected $_emptyListMessage = 'нет комментариев';
	
    public function GetList($ctrlName, $blog, $entry)
    {
        $this->ctrlName = $ctrlName;
        $this->blog = $blog;
        $this->entry = $entry;
        
        $objects = Mozg_Mapper::Get('Comments')->GetList(array('entryId' => $entry->GetId()));
        
        Mozg::SubAction()->Set('Right Sidebar', array($this, 'GetArticleInfo'), array($ctrlName, $blog, $entry));

        $icons = array(
        	array(
        	'add' => array(
        					'title' => 'ADD',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=add&blog=' .$blog->GetId())
        					),
        	),
        	
        	array(
        	'edit' => array(
        					'title' => 'EDIT',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=add&blog=' .$blog->GetId(). '&id=' .$entry->GetId())
        					),
        	'articles' => array(
        					'title' => 'режим выбора статей по теме',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=list&blog=' .$blog->GetId(). '&main_theme_id=' .$entry->GetId())
        					),
        	'delete' => array(
        					'title' => 'DELETE_ARTICLE?',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$ctrlName. '&action=del&blog=' .$blog->GetId(). '&id=' .$entry->GetId())
        					),
        	),
        	
        );
		
        return $this->GetTpl('Base')->LoadTemplate(Mozg_Lang::_('COMMENTS'), $this->CreateList($objects), $icons);
    }

    public function GetArticleInfo($ctrlName, $blog, $entry)
    {
    	if (!$entry) return '';
    	
        $this->ctrlName = $ctrlName;
        $this->blog = $blog;
        $this->entry = $entry;
    	
        return $this->GetTpl('Base')->RightBlock(Mozg_Lang::_('ARTICLE'), $this->render('articles/_out_article_info.phtml'));
    }
    
	protected function GetCellComment($obj)
	{
		$this->obj = $obj;
		return $this->render('articles/comments/_comment.phtml');
	}
	
	protected function GetCellIcons($obj)
	{
        $icons = array(
        	'delete' => array(
        					'title' => 'Удалить комментарий?',
        					'url' => Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=delcomment&blog=' .$this->blog->GetId(). '&id=' .$this->entry->GetId(). '&comment=' .$obj->GetId())
        					),

        );
		return $this->GetTpl('Icon')->GetIconSet($icons, 'list');
	}
}